<?php

use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\grid\GridView;

/**
 * @var yii\web\View $this
 * @var amnah\yii2\user\Module $module
 * @var array $actions
 */

$module = $this->context->module;//得到Yii2的当前的控制器module

$this->title = Yii::t('user', 'Yii 2 User');
?>
<div class="user-default-index">

    <h1>Yii 2 User Module - <?= $module->getVersion(); ?></h1>
    <h3>Actions in this module</h3>

    <p>
        <em><strong>Note:</strong> Some actions may be unavailable depending on if you are logged in/out, or as an
            admin/regular user</em>
    </p>
    <p>
        <?php
            //创建区域逻辑
            // 如果创建
            echo Html::a(Yii::t('region', 'Create') . $region_name. Yii::t('region', $region_type_name) , ['create','region_type_id'=>$region_type_id, 'region_type_name'=>$region_type_name, 'parent_region_id'=>$parent_region_id], ['class' => 'btn btn-success']);
        ?>
        <?php

            if ($region_type_name!='Provine')
            {
                echo Html::a(Yii::t('region', 'Back')   , Yii::$app->request->getReferrer() , ['class' => 'btn btn-success']);
            }


        ?>
    </p>

    <?php
        echo GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
                // ...
                [
                    'class' => 'yii\grid\CheckboxColumn',//复选框
                    'multiple' => true,
                    'name' => 'uid',
                    'filterOptions'=>['style'=>'width:30px']
                ],

                [
                    'attribute' => 'id',
                    'filterOptions'=>['style'=>'width:30px']
                ],

                [
                    'label'=>'区域名称',
                    'attribute'=>'region_name',
                    'options'=>['style'=>'width:180px']
                ],
                [
                    'class' => 'app\common\grid\ActionColumn',
                    'options'=>['style'=>'width:180px'],
                    'buttons' => [
                        'view' => function ($url, $model, $key) {
                            return Html::a(Html::tag('span', '查看', ['class' => "glyphicon fa fa-eye"]), ['view', 'id'=>$model->id, 'region_type_id'=>$model->region_type_id, 'region_name'=>$model->region_name], ['class' => "btn btn-xs btn-success",'label'=>'查看下级目录', 'title' => '查看下级目录']);
                        },
                    ]
                ],
            ],
        ]);


    ?>


</div>
